package cn.tedu.csmall.order.webapi.kafka;

import cn.tedu.csmall.commons.pojo.order.entity.Order;
import com.google.gson.Gson;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

@Component
public class Consemer {
    @KafkaListener(topics = Producer.TOPIC_KEY)
    public void received(ConsumerRecord<String, String> record){
        String json = record.value();
        Gson gson = new Gson();
        Order order = gson.fromJson(json, Order.class);
        System.out.println(order);
    }
}
